package ca.seia.comp6521.a2.itemsetalgorithms;

import gnu.trove.map.TIntIntMap;
import gnu.trove.map.hash.TIntIntHashMap;

import java.util.Arrays;

/**
 * @author itoe
 *
 */
public class BitVector {

	private final int biggestFrequentItem;
	private final int nbrFrequentItems;
	
	private final boolean[] bitVector;
	
	public BitVector(int nbrFrequentItems,int biggestFrequentItem, boolean[] bitVector) {
		this.nbrFrequentItems = nbrFrequentItems;
		this.biggestFrequentItem = biggestFrequentItem;
		this.bitVector = bitVector;
	}
	
	public TIntIntMap generateRenamedFrequentIdMap() {
		TIntIntMap idMap = new TIntIntHashMap();
		int id=0;
		for(int frequentItemIndex = 0 ; frequentItemIndex < bitVector.length ; frequentItemIndex++) {
			if(bitVector[frequentItemIndex]) {
				idMap.put(frequentItemIndex, id);
				id++;
			}
		}
		return idMap;
	}

	public int getBiggestFrequentItem() {
		return biggestFrequentItem;
	}
	
	public boolean isFrequentItem(int item) {
		return bitVector[item];
	}

	public boolean[] getBitVector() {
		return bitVector;
	}
	
	public int getNbrFrequentItems() {
		return nbrFrequentItems;
	}

	@Override
	public String toString() {
		return "BitVector [biggestFrequentItem=" + biggestFrequentItem + ", nbrFrequentItems=" + nbrFrequentItems + ", bitVector=" + Arrays.toString(bitVector)
				+ "]";
	}
	
}
